
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>IM即时通讯之前之前怎么做的 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>IM即时通讯之前之前怎么做的 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">轮询（Polling）和长轮询（Long Polling）在处理无新消息的请求时有何根本区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">对于轮询，如果服务器没有新消息，会立即返回一个空响应。而对于长轮询，服务器会保持该连接，直到有新的消息可供发送时才会返回响应。</div>
          </div>
          <div class="card-source">来源: 1. 轮询（Polling）与 2. 长轮询（Long Polling）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">为什么说长轮询（Long Polling）虽然比普通轮询更实时，但可能会增加服务器的资源消耗？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为服务器需要为每个客户端保持一个活动的连接，直到有新消息为止。这种长时间的连接占用会增加服务器的资源消耗，并可能影响其并发处理能力。</div>
          </div>
          <div class="card-source">来源: 2. 长轮询（Long Polling）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">与传统的HTTP轮询相比，WebSocket协议的核心优势是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">WebSocket的核心优势在于它建立了持久的双向通信通道，从而实现低延迟和强实时性。这使得它在开销和效率上优于HTTP轮询，特别适合高频次的双向通信场景。</div>
          </div>
          <div class="card-source">来源: 3. WebSocket</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">WebSocket 和服务器推送（SSE）在通信方向上有什么核心区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">核心区别在于，WebSocket支持双向通信，客户端和服务器都可以随时互相发送数据。而SSE只支持服务器到客户端的单向数据推送，客户端无法通过同一连接向服务器发送数据。</div>
          </div>
          <div class="card-source">来源: 3. WebSocket 和 4. 服务器推送（Server-Sent Events, SSE）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">服务器推送事件（Server-Sent Events, SSE）技术存在的主要局限性是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">SSE的主要局限性是它只支持服务器单向推送数据给客户端，客户端无法通过同一连接发送数据，功能较为单一。</div>
          </div>
          <div class="card-source">来源: 4. 服务器推送（Server-Sent Events, SSE）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">根据文档，XMPP协议作为一种成熟的即时消息协议，其主要缺点体现在哪两个方面？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">XMPP的主要缺点体现在两个方面：第一，其基于XML的格式导致数据冗余较大；第二，协议本身较为复杂，导致初次实现的成本较高。</div>
          </div>
          <div class="card-source">来源: 5. XMPP（Extensible Messaging and Presence Protocol）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">MQTT协议主要适用于哪类场景，并且它的核心工作模式是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">MQTT是一种轻量级协议，主要适用于低带宽、不稳定网络环境的设备通信，常用于物联网（IoT）领域。其核心工作模式是发布/订阅模式。</div>
          </div>
          <div class="card-source">来源: 6. MQTT（Message Queuing Telemetry Transport）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">请描述轮询（Polling）的基本工作原理。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">客户端以固定的时间间隔（例如每隔几秒）向服务器发送HTTP请求，询问是否有新消息。如果服务器有新消息，则返回消息数据；如果没有，则返回空响应。</div>
          </div>
          <div class="card-source">来源: 1. 轮询（Polling）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">MQTT协议在保证消息传输方面提供了什么关键特性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">MQTT协议支持QoS（Quality of Service）级别，这一特性可以保证消息的可靠传输，即使在不稳定的网络环境中也是如此。</div>
          </div>
          <div class="card-source">来源: 6. MQTT（Message Queuing Telemetry Transport）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
